package com.google.code.yargon.util;

import java.util.Properties;
import org.apache.log4j.*;

/**
 * 
 * @author Mika Myllynen
 *
 */
public class LogUtil {
	
	// Logger instance
	private static Logger instance = null;
		
	/**
	 * Get logger instance - this should be called when first time instancing logger
	 * Later use getInstance()
	 * 
	 * @param props
	 * @return
	 */
	public static Logger getInstance(Properties props) {
		if(null == instance) {
			PropertyConfigurator.configure(props);
			instance = Logger.getLogger("Yargon"); 
		}
		return instance;
	}
	
	/**
	 * Get logger instance
	 * 
	 * @return
	 */
	public static Logger getInstance() {
		if(null == instance) {
			System.err.println("Logger was not ready!");
			System.exit(1);
		}
		return instance;
	}
}
